import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/common/text_arrow_item.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///常用设备
class DeviceManage extends StatelessWidget {
  const DeviceManage({super.key});

  @override
  Widget build(BuildContext context) {
    return BasePage(
      title: "常用设备",
      iconType: IconType.back,
      children: [
        Container(
          padding: EdgeInsets.fromLTRB(18.w, 10.w, 18.w, 10.w),
          child: Text(
            "该功能旨在保护账户信息安全，如有异常，请至账户安全修改登 录密码",
            style: TextStyle(fontSize: 12, fontWeight: FontWeight.w300, color: Tools.fromHex("#666666")),
          ),
        ),
        // ListItem(texts: "菜菜的设备", ontap: ()=>{}),
        Container(
          padding: EdgeInsets.fromLTRB(18.w, 20.w, 18.w, 10.w),
          child: Text(
            "已退出的登录设备",
            style: TextStyle(fontSize: 12, fontWeight: FontWeight.w300, color: Tools.fromHex("#666666")),
          ),
        ),
        DeviceItme(deviceName: "Android 设备", time: "星期四 09:00"),
        DeviceItme(deviceName: "IOS 设备", time: "星期四 09:00"),
        DeviceItme(deviceName: "redmi k20 Pro", time: "星期四 09:00"),
      ],
    );
  }
}

class DeviceItme extends StatelessWidget {
  final String deviceName;
  final String time;

  const DeviceItme({super.key, required this.deviceName, required this.time});

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.only(left: 18.w, right: 18.w),
        color: Colors.white,
        child: Container(
          decoration: bottom_gary_border,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              SizedBox(
                height: 56.h,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      deviceName,
                      style: TextStyle(fontSize: 14, fontWeight: FontWeight.w300, color: Tools.fromHex("#333333")),
                    ),
                    Text(
                      time,
                      style: TextStyle(fontSize: 10, fontWeight: FontWeight.w300, color: Tools.fromHex("#999999")),
                    ),
                  ],
                ),
              ),
              //右侧按钮
              BaseInteractive(
                onClick: () => {Tools.showModal(content: "确定要删除该设备么？")},
                childWidget: Text(
                  "删除该设备",
                  style: TextStyle(fontSize: 14, fontWeight: FontWeight.w300, color: Tools.fromHex("#F83F2D")),
                ),
              )
            ],
          ),
        ));
  }
}
